﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AssemblyProvider.Web;
using AbstraX.ServerInterfaces;
using SLControlProvider.Web;
using System.Diagnostics;
using AbstraX.Contracts;
using AbstraX.AssemblyInterfaces;

namespace TestControlProvider
{
    class Program
    {
        private class Host : IDomainHostApplication
        {
            public IAssemblyProviderService AssemblyProviderService
            {
                get
                {
                    return new AssemblyProviderService();
                }
                set
                {
                    throw new NotImplementedException();
                }
            }

            public string ImageEditorUrl
            {
                get
                {
                    throw new NotImplementedException();
                }
                set
                {
                    throw new NotImplementedException();
                }
            }

            public string GetImageEditorUrl()
            {
                throw new NotImplementedException();
            }

            public List<IVSSolution> Solutions
            {
                get { throw new NotImplementedException(); }
            }

            public void SetStatus(string status)
            {
                throw new NotImplementedException();
            }

            public List<string> LatestStatus
            {
                get { throw new NotImplementedException(); }
            }

            public Dictionary<string, IAbstraXProviderService> RegisteredServices
            {
                get { throw new NotImplementedException(); }
            }

            public AbstraX.Bindings.Interfaces.IBindingsTreeCache BindingsTreeCache
            {
                get { throw new NotImplementedException(); }
            }


            public AbstraX.Bindings.Interfaces.IBindingsGenerator BindingsGenerator
            {
                get { throw new NotImplementedException(); }
            }


            public Microsoft.Practices.Unity.IUnityContainer PipelineContainer
            {
                get { throw new NotImplementedException(); }
            }

            public void PostEventShowUI(string uiComponentURL, string parms)
            {
                throw new NotImplementedException();
            }

            public void PostEventBuildMessage(string message)
            {
                throw new NotImplementedException();
            }

            public void PostEventBuildComplete()
            {
                throw new NotImplementedException();
            }

            public void PostEventError(string errorMessage)
            {
                throw new NotImplementedException();
            }

            public void PostEventPercentComplete(float percentComplete)
            {
                throw new NotImplementedException();
            }

            public Queue<AbstraX.BuildUIQueueEntry> BuildUIQueue
            {
                get { throw new NotImplementedException(); }
            }

            public IEventsService EventsService
            {
                get
                {
                    throw new NotImplementedException();
                }
                set
                {
                    throw new NotImplementedException();
                }
            }


            public bool FinishBuildWithDefaults
            {
                get
                {
                    throw new NotImplementedException();
                }
                set
                {
                    throw new NotImplementedException();
                }
            }


            public void PostEventShowUI(string uiComponentURL, string parms, IBuildUIDaemon buildUIDaemon, TimeSpan waitTimeout)
            {
                throw new NotImplementedException();
            }

            public void ClearQueue()
            {
                throw new NotImplementedException();
            }

            public IPipelineService PipelineService
            {
                get { throw new NotImplementedException(); }
            }


            public Dictionary<string, ICodeTemplate> ProjectGroupTemplates
            {
                get { throw new NotImplementedException(); }
            }

            public Dictionary<string, ICodeTemplate> ProjectTemplates
            {
                get { throw new NotImplementedException(); }
            }

            public Dictionary<string, ICodeTemplate> ItemTemplates
            {
                get { throw new NotImplementedException(); }
            }
        }

        static void Main(string[] args)
        {
            var service = new SLControlProviderService();
            var indent = 0;

            service.DomainServiceHostApplication = new Host();

            var root = service.GetSLControlsRoot();

            Console.WriteLine(new string(' ', indent) + "Control assemblies");

            indent += 2;

            foreach (IElement assembly in root.RootElements.Where(e => !e.DataType.IsAbstract))
            {

                Console.WriteLine(new string(' ', indent) + assembly.Name + "\r\n");

                Console.WriteLine(new string(' ', indent) + "Controls:\r\n");

                indent += 2;

                foreach (IElement control in assembly.ChildElements)
                {
                    Console.WriteLine(new string(' ', indent) + control.Name);

                    indent += 2;

                    Console.WriteLine("\r\n" + new string(' ', indent) + "Elements:\r\n");

                    foreach (IElement childElem in control.ChildElements)
                    {
                        Console.WriteLine(new string(' ', indent) + childElem.Name);
                    }

                    Console.WriteLine("\r\n" + new string(' ', indent) + "Attributes:\r\n");

                    foreach (IAttribute attribute in control.Attributes)
                    {
                        Console.WriteLine(new string(' ', indent) + attribute.Name);
                    }

                    Console.WriteLine("\r\n");

                    indent -= 2;
                }

                indent -= 2;

                Console.WriteLine("\r\n");
            }

            indent -= 2;

            Console.ReadLine();
        }
    }
}
